package com.ruibang.glass.iso.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruibang.glass.iso.domain.req.FileManageReq;
import com.ruibang.glass.iso.entity.FileManage;
import com.ruibang.glass.iso.service.impl.FileManageService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @Author: songJinKang
 * @CreateTime: 2024-06-05  15:27
 * @Description: TODO
 * @Version: 1.0
 */

@RestController
@RequestMapping("/api/iso/fileManage")
@Api(value = "文件管理", tags = {"文件管理"})
public class FileManageController {

    @Autowired
    private FileManageService fileManageService;

    @PostMapping("/pageQuery")
    @ApiOperation(value = "分页查询文件类别信息", response = ResultBody.class)
    public ResultBody<IPage<FileManage>> pageQuery(@RequestBody FileManageReq fileManageReq) {
        return ResultBody.success(fileManageService.pageQuery(fileManageReq));
    }

    @PostMapping("/save")
    @ApiOperation(value = "新增文件管理", response = ResultBody.class)
    public ResultBody save(@RequestBody @Valid FileManage fileManage) {
        fileManageService.saveInfo(fileManage);
        return ResultBody.success();
    }

    @GetMapping("/processNotice/{businessId}")
    @ApiOperation(value = "流程处理通知", response = ResultBody.class)
    public ResultBody processNotice(@PathVariable("businessId") String businessId) {
        fileManageService.processNotice(businessId);
        return ResultBody.success();
    }

    @GetMapping("/abolishProcessNotice/{businessId}")
    @ApiOperation(value = "废止流程通知", response = ResultBody.class)
    public ResultBody abolishProcessNotice(@PathVariable("businessId") String businessId) {
        fileManageService.abolishProcessNotice(businessId);
        return ResultBody.success();
    }

    @GetMapping("/getDetail/{manageId}")
    @ApiOperation(value = "获取详情信息", response = ResultBody.class)
    public ResultBody getDetail(@PathVariable("manageId") String manageId) {
        return ResultBody.success( fileManageService.getDetail(manageId));
    }

    @GetMapping("/getDetailByAbolishId/{abolishId}")
    @ApiOperation(value = "根据废止Id获取详情信息", response = ResultBody.class)
    public ResultBody getDetailByAbolishId(@PathVariable("abolishId") String abolishId) {
        return ResultBody.success(fileManageService.getDetailByAbolishId(abolishId));
    }

    @PostMapping("/edit")
    @ApiOperation(value = "修改文件管理", response = ResultBody.class)
    public ResultBody edit(@RequestBody @Valid FileManage fileManage) {
        fileManageService.edit(fileManage);
        return ResultBody.success();
    }

    @PostMapping("/abolish")
    @ApiOperation(value = "废止", response = ResultBody.class)
    public ResultBody abolish(@RequestBody @Valid FileManage fileManage) {
        fileManageService.abolish(fileManage);
        return ResultBody.success();
    }
}
